//@Author: wulinlin
//@Description:
//@File:  enterprise
//@Version: 1.0.0
//@Date: 2024/04/17 22:48

package enterprise_dao

import (
	"context"
	"ebip/internel/repository/dao"
	"gorm.io/gorm"
)

type EnterpriseDAO interface {
	InsertEnterpriseBaseInfo(ctx context.Context, data dao.EnterpriseBasicModel) error
	BatchInsertEnterpriseBaseInfo(ctx context.Context, data []dao.EnterpriseBasicModel) error
}

func NewEnterpriseDAO(db *gorm.DB) EnterpriseDAO {
	return &enterpriseDAO{
		db: db,
	}
}

type enterpriseDAO struct {
	db *gorm.DB
}

func (e *enterpriseDAO) InsertEnterpriseBaseInfo(ctx context.Context, data dao.EnterpriseBasicModel) error {
	err := e.db.WithContext(ctx).Model(&dao.EnterpriseBasicModel{}).Create(&data).Error
	if err != nil {
		panic(err)
	}
	// TODO 处理唯一索引冲突的问题
	return err
}

// BatchInsertEnterpriseBaseInfo
//
//	@Description: GORM批量插入 一定要执行原生SQL吗？？？？ 不理解
//	@receiver e
//	@param ctx
//	@param bizId
//	@param biz
//	@param data
//	@return error
func (e *enterpriseDAO) BatchInsertEnterpriseBaseInfo(ctx context.Context, data []dao.EnterpriseBasicModel) error {
	//TODO implement me
	panic("implement me")
}
